<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>location</title>
	<style type="text/css">
		body {
			background-color: #ccc;
			width: 100%;
			height: 100%;
			display: flex;
			justify-content: center;
		}

		div {
			position: absolute;
			top: 50%;
		}
	</style>
	<script>
		window.onload = function () {			
			console.log(location.href);
			console.log(location.host); 
			console.log(location.hostname); 
			console.log(location.port); 
			console.log(location.protocol);
			console.log(location.pathname); 
			console.log(location.search);
			console.log(location.origin); 
			console.log(location.hash); 
		}
		function go() {
			// location.href="http://www.baidu.com";
			location.assign("http://www.baidu.com");
			// location.replace("http://www.baidu.com");
			// location.reload(); // 刷新当前页面
		}
		function goimg() {
			location.assign("file:///D:/Project/kecheng/CY9/html_code/CSS%E5%9F%BA%E7%A1%80/img/a.jpg");
		}
		function gohtml() {
			location.assign("history.html");
		}
	</script>
</head>

<body>
	<div>
		<button onclick="go()">跳转去百度</button>
		<button onclick="goimg()">跳转去图片</button>
		<button onclick="gohtml()">跳转去html</button>
	</div>
</body>

</html>